import { Module } from 'vuex';
import { Session } from '/@/utils/storage';

import { DecoratorInfoState, RootStateTypes } from '/@/store/interface/index';

const decoratorModule: Module<DecoratorInfoState, RootStateTypes> = {
	namespaced: true,
	state: {
		terminal: 1,
		terminalContent: {
			width: 415,
			title: '',//网页标题
			viewed: false,//只读状态
			bgColor: '',
			imageUrl: '',
			confirm: false,//删除不提示确认框
		},
		componentsData: [],
		activeComponent: {},
		componentsFormData: {}, //表单组件数据
	},
	mutations: {
		getTerminal(state, terminal) {
			state.terminal = terminal;
		},
		getTerminalContent(state, terminalContent) {
			state.terminalContent = terminalContent;
		},
		getComponentsData(state, componentsData) {
			state.componentsData = componentsData;
		},
		getActiveComponent(state, activeComponent) {
			state.activeComponent = activeComponent;
		},
		getComponentsFormData(state, componentsFormData) {
			state.componentsFormData = componentsFormData;
		}
	},
	actions: {
		async setTerminal({ commit }, terminal) {
			commit('getTerminal', terminal);
		},
		async setTerminalContent({ commit }, terminalContent) {
			commit('getTerminalContent', terminalContent);
		},
		async setComponentsData({ commit }, componentsData) {
			commit('getComponentsData', componentsData);
		},
		async setActiveComponent({ commit }, activeComponent) {
			commit('getActiveComponent', activeComponent);
		},
		async setComponentsFormData({ commit }, componentsFormData){
			commit('getComponentsFormData', componentsFormData);
		}
	},
};

export default decoratorModule;
